<!-- 确认扣款 -->
<div class="float-confirm float-confirm-dialog js_minusDealerOrderDiv" style="display: none; width:auto;">
    <div class="float-confirm-con">
        <h2 class="fs22 blue2 line">确认扣款
            <span style="font-size: .7em; color: #000; margin-left: .5em;" class="js_order_user"></span><span style="font-size: .7em; color: #000; margin-left: .5em;">的订单</span><span style="font-size: .7em; color: #000; margin-left: .5em;" class="js_order_number"></span>
        </h2>
        <div class="line" style="width: 440px;">
            <table style="width:100%;">
                <tr>
                    <td>&nbsp;</td>
                    <td width="12%">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td width="12%">&nbsp;</td>
                    <td align="right">
                        <label class="label label-default">用户余额</label>
                        <br/>
                        <span style="font-size:1.5em; color:#999999" class="js_user_money"></span>
                    </td>
                </tr>
                <tr>
                    <td colspan="5" align="right"><span style="line-height:24px; font-size:3em; color:#999999">-</span></td>
                </tr>
                <tr>
                    <td align="right">
                        <label class="label label-default">订单总价</label>
                        <br/>
                        <span style="font-size:1.5em; color:#999999" class="js_price"></span>
                    </td>
                    <td align="right"><span style="line-height:24px; font-size:3em; color:#999999">-</span></td>
                    <td align="right">
                        <label class="label label-success">已付</label>
                        <br/>
                        <span style="font-size:1.5em; color:#009600" class="js_paied"></span>
                    </td>
                    <td align="right"><span style="line-height:24px; font-size:3em; color:#999999">=</span></td>
                    <td align="right">
                        <label class="label label-danger">应扣</label>
                        <br/>
                        <span style="font-size:1.5em; color:#a01719" class="js_need_to_pay"></span>
                    </td>
                </tr>
                <tr>
                    <td height="2px" style="font-size: 0; background-color: #999999" colspan="5">&nbsp;</td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td align="right">
                        <label class="label label-info">扣款后余额</label>
                        <br/>
                        <span style="font-size:1.5em; color:#5bc0de" class="js_user_overage"></span>
                    </td>
                </tr>
            </table>
            <p>
            </p>
        </div>
        <div class="float-confirm-btns" style="padding-bottom:30px;">
            <a class="btn btn-default btn-sm right js_cancel" href="javascript:void(0);">取消</a>
            <a class="btn btn-success btn-sm right js_confirm" href="javascript:void(0);">确定</a>
        </div>
    </div>
</div>
<script>
    (function ($) {

        var el = $('.js_minusDealerOrderDiv');
        var nodes = {
            price: el.find('.js_price'),
            paied: el.find('.js_paied'),
            order_number: el.find('.js_order_number'),
            order_user: el.find('.js_order_user'),
            need_to_pay: el.find('.js_need_to_pay'),
            user_money: el.find('.js_user_money'),
            user_overage: el.find('.js_user_overage')
        };

        var lock = false;

        var dealerMinus = function (order_id) {
            showConfirmDiv(el, order_id);
            $.pageMask.show();
            for (var i in nodes) {
                if (nodes.hasOwnProperty(i)) {
                    nodes[i].empty();
                    nodes[i].hide();
                }
            }
            getRTData();
        };

        function getRTData() {
            var order_id = el.data('id');
            $.post(
                    "{AnUrl('order/admin/ajax_get_real_time_order_data')}",
                    {
                        order_id: order_id
                    },
                    function (ret) {
                        if (ret && ret.flag === 0 && ret.response) {
                            var order_info = ret.response;
                            nodes.price.show().html(order_info.price);
                            nodes.paied.show().html(order_info.pay_user_money);
                            nodes.order_number.show().html(order_info.no);
                            nodes.order_user.show().html(order_info.user_info.realname);
                            nodes.need_to_pay.show().html(order_info.need_to_pay);
                            nodes.user_money.show().html(order_info.user_info.user_money);
                            nodes.user_overage.show().html(order_info.overage);

                            return;
                        }
                        showMsg(ret.message || "接口请求失败, 请稍后重试");
                        el.hide();
                        $.pageMask.hide();
                    }
            )
        }

        // 确认到货显示
        $('.js_minusDealerOrder').click(function () {
            var order_id = $(this).closest('tr').data('id');
            dealerMinus(order_id);
        });

        // 确认到货操作
        el.find('.js_confirm').click(function () {

            var order_id = el.data('id');
            var params = {
                order_id: order_id
            };

            showConfirm('确认扣款?', 1, function () {
                $.post(
                        "{AnUrl('order/admin/operation/dealer_action_minus')}",
                        params,
                        function (ret) {
                            if (ret && ret.flag === 0) {
                                showMsg(ret.message);
                                setTimeout(function () {
                                    window.location.reload();
                                }, 1500);
                                return;
                            }
                            showMsg(ret.message || "接口请求失败, 请稍后重试");
                            el.hide();
                            $.pageMask.hide();
                        }
                );
            });
        });

        // 注册到全局操作
        window.order_operation.DEALER_ACTION_MINUS = dealerMinus;
        console.log('order_operation.DEALER_ACTION_MINUS added! 确认扣款');

    })(jQuery);
</script>
<!-- /确认扣款 -->